package com.open.cloud.rbac.service.application.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.open.cloud.rbac.entity.application.CoreApplicationInterface;
import com.open.cloud.rbac.mapper.application.CoreApplicationInterfaceMapper;
import com.open.cloud.rbac.object.application.CoreApplicationInterfaceDto;
import com.open.cloud.rbac.service.application.ICoreApplicationInterfaceService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 应用接口表 服务实现类
 * </p>
 *
 * @author wangzengzhou01
 * @since 2024-12-23
 */
@Service
public class CoreApplicationInterfaceServiceImpl extends ServiceImpl<CoreApplicationInterfaceMapper, CoreApplicationInterface>
        implements ICoreApplicationInterfaceService {

    @Resource
    private CoreApplicationInterfaceMapper appInterfaceMapper;

    /**
     * 分页查询接口
     *
     * @param appInterfaceDto
     * @return
     */
    @Override
    public IPage<CoreApplicationInterface> getAppInterfacePage(CoreApplicationInterfaceDto appInterfaceDto) {
        LambdaQueryWrapper<CoreApplicationInterface> queryWrapper = Wrappers.<CoreApplicationInterface>lambdaQuery()
                .eq(ObjectUtils.isNotEmpty(appInterfaceDto.getAppId()), CoreApplicationInterface::getApplicationId, appInterfaceDto.getAppId())
                .eq(ObjectUtils.isNotEmpty(appInterfaceDto.getModuleName()), CoreApplicationInterface::getModuleName, appInterfaceDto.getModuleName());
        IPage<CoreApplicationInterface> page = new Page<>(appInterfaceDto.getPageNo(), appInterfaceDto.getPageSize());
        IPage<CoreApplicationInterface> data = appInterfaceMapper.selectPage(page, queryWrapper);
        return data;
    }
}
